package com.chapter.sample.answer.controller;

import com.chapter.sample.answer.redpackage.RedPackage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 抢红包
 */
@RestController
public class RedPackageController {

    @Autowired
    private RedPackage redPackage;

    /**
     * 发红包
     *
     * @param totalMoney
     * @param redPackageNumber
     * @return
     */
    @RequestMapping("/send")
    public String sendRedPackage(int totalMoney, int redPackageNumber) {
        return redPackage.sendRedPackage(totalMoney, redPackageNumber);
    }

    @RequestMapping("/rob")
    public String robRedPackage(String redPackageKey,String userId) {
        return redPackage.robRedPackage(redPackageKey, userId);
    }
}
